Ruby on Rails:为文件夹中的每个文件生成HTML

我目前有一个包含小* .ogg文件列表的文件夹,我想将其插入到我/ public文件夹的html.erb页面中。

代码在video标签内 – 我想使用Ruby扫描文件夹并为它在文件夹中找到的每个video生成video片段。 除video文件名外,video之间的代码保持不变。

生成的页面将是可播放video的列表。

任何建议都很棒。

# assumes the current dir contains the ogg files html = '' Dir.glob("*.ogg") do |file| html += "" end puts html #